import os

xdir = os.path.abspath(os.getcwd())
while True:
    print(xdir)
    xdir2 = os.path.join(xdir, '..')
    xdir2 = os.path.abspath(xdir2)
    if xdir == xdir2:
        break
    xdir = xdir2
